//package com.chenl.provider.DEMOS.Spring.幂等注解.Interceptor;
//
//import com.alibaba.fastjson.JSONObject;
//import com.chenl.provider.DEMOS.日志相关.全链路日志以及Spring线程池装饰器的使用.LogThreadLocal;
//import com.chenl.provider.DEMOS.日志相关.全链路日志以及Spring线程池装饰器的使用.LogVo;
//import com.chenl.provider.util.MDCUtils;
//import com.chenl.provider.util.TtlThreadLocal;
//import lombok.extern.slf4j.Slf4j;
//import org.slf4j.MDC;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.net.URLDecoder;
//
//@Slf4j
//public class MyInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        System.out.println("1 幂等注解,拦截了");
//        String traceId = request.getHeader("traceId");
//        String traceIdKey="traceId";
//        if (traceId!=null){
//            log.info("注入请求头中的traceID");
//            MDC.put(traceIdKey,traceId);
//            return true;
//        }
//        traceId= MDCUtils.mdc();
//        log.info("注入新生成的的traceID:{}",traceId);
//        request.setAttribute(traceIdKey,traceId);
//        MDC.clear();
//        MDC.put(traceIdKey,traceId);
//        TtlThreadLocal.set(MDC.getCopyOfContextMap());//利用阿里的TTL设置上下文对象供子线程传递
////        LogThreadLocal.set(JSONObject.parseObject(request.getHeader("log")!=null? URLDecoder.decode(request.getHeader("log")):"", LogVo.class));
//        return true;
//    }
//}